package com.len.controller;

import com.len.base.BaseController;
import com.len.entity.SpAddress;
import com.len.service.SpAddressService;
import com.len.util.CommonUtil;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("address")
public class SpAddressController extends BaseController<SpAddress> {
    @Autowired
    private SpAddressService spAddressService;
    @RequestMapping("/save")
    public String save(SpAddress spAddress){
        try {
            spAddressService.insert(spAddress);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    @RequestMapping("/update")
    public String update(SpAddress spAddress){
        try {
            spAddressService.updateByPrimaryKey(spAddress);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    @RequestMapping("/show")
    @ResponseBody
    public Map show(SpAddress spAddress){
        try {
            String username= CommonUtil.getUser().getUsername();
            return spAddressService.selectByUserName(username);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
